package test;
/*筛选字符串。

        - 定义数组，存入多个字符串。
        - 删除长度大于5的字符串，打印删除后的数组。*/

public class Test5 {
    public static void main(String[] args) {
        StringBuffer[] arr=new StringBuffer[5];
        {
            arr[0]=new StringBuffer("abc");
            arr[1]=new StringBuffer("abcd");
            arr[2]=new StringBuffer("abcdef");
            arr[3]=new StringBuffer("abcfkhjh");
            arr[4]=new StringBuffer("fgkgjgofjffj");
        }
        System.out.println("删除前的字符串");
        int index=0;
        for (StringBuffer stringBuffer : arr) {
            if (stringBuffer.length()>5){
                index++;
            }
            System.out.print(stringBuffer.toString()+"\t,");
        }
        for (StringBuffer stringBuffer : arr) {
            if (stringBuffer.length()>5){
                stringBuffer.delete(0,stringBuffer.length());
            }
        }
        System.out.println();
        System.out.println("删除后为：");
        for (StringBuffer stringBuffer : arr) {
            System.out.print(stringBuffer.toString()+"\t");
        }
    }
}
